<?php

namespace PhpYes\Modules\Log;


abstract class LogRecordBase implements LogRecordInterface
{
    /** @var array */
    private $config;

    /**
     * 日志级别
     * @var string - refer LogLevel
     */
    protected $level;

    /**
     * 用户记的日志内容
     * @var string
     */
    protected $message;

    /**
     * 日志时间
     * @var \DateTime
     */
    protected $dt;

    /**
     * LogRecordBase constructor.
     * @param array $config
     */
    public function __construct($config)
    {
        $this->config = $config;
        $this->level = LogLevel::ERROR;
        $this->message = '';
        $this->dt = new \DateTime();
    }

    /**
     * get 日志tag
     * @return null|string
     */
    public function getTag()
    {
        return empty($this->config['tag']) ? null : trim($this->config['tag']);
    }

    /**
     * get 日志级别
     * @return string - refer LogLevel
     */
    public function getLevel()
    {
        return $this->level;
    }

    /**
     * get 日志时间
     * @return \DateTime
     */
    public function getDateTime()
    {
        return $this->dt;
    }

    /**
     * get 用户记的日志内容
     * @return string
     */
    public function getMessage()
    {
        return $this->message;
    }
}